package org.jeecg.modules.hotel.requisition.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.basic.demo.bed.entity.LwgyBaseBed;
import org.jeecg.modules.basic.demo.bed.mapper.LwgyBaseBedMapper;
import org.jeecg.modules.basic.demo.bed.service.ILwgyBaseBedService;
import org.jeecg.modules.basic.demo.student.entity.LwgyBaseStudent;
import org.jeecg.modules.basic.demo.student.service.ILwgyBaseStudentService;
import org.jeecg.modules.hotel.arrangement.controller.LwgyHotelArrangementController;
import org.jeecg.modules.hotel.arrangement.controller.LwgyHotelArrangementHolidayController;
import org.jeecg.modules.hotel.arrangement.entity.ImportHoildayStu;
import org.jeecg.modules.hotel.arrangement.entity.ImportStuHotel;
import org.jeecg.modules.hotel.arrangement.service.ILwgyHotelArrangementService;
import org.jeecg.modules.hotel.history.entity.LwgyHotelHistory;
import org.jeecg.modules.hotel.history.service.ILwgyHotelHistoryService;
import org.jeecg.modules.hotel.requisition.entity.LwgyHotelHoliday;
import org.jeecg.modules.hotel.requisition.entity.LwgyHotelRequisition;
import org.jeecg.modules.hotel.requisition.mapper.LwgyHotelRequisitionMapper;
import org.jeecg.modules.hotel.requisition.service.ILwgyHotelRequisitionService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;

/**
* @Description: 假期管理
* @Author: sn
* @Date:   2022-03-07
* @Version: V1.0
*/
@Api(tags="假期管理")
@RestController
@RequestMapping("/requisition/lwgyHotelHoliday")
@Slf4j
public class LwgyHotelHolidayController extends JeecgController<LwgyHotelRequisition, ILwgyHotelRequisitionService> {
   @Autowired
   private ILwgyHotelRequisitionService lwgyHotelRequisitionService;

   @Autowired
   private LwgyBaseBedMapper lwgyBaseBedMapper;

   @Autowired
   private LwgyHotelRequisitionMapper lwgyHotelRequisitionMapper;

   @Autowired
   private ILwgyHotelArrangementService lwgyHotelArrangementService;

   @Autowired
   private ILwgyHotelHistoryService lwgyHotelHistoryService;

   @Autowired
   private ILwgyBaseBedService lwgyBaseBedService;

   @Autowired
   private ILwgyBaseStudentService lwgyBaseStudentService;

   @Autowired
   private ISysBaseAPI sysBaseAPI;

   /**
    * 分页列表查询
    *
    * @param lwgyHotelRequisition
    * @param pageNo
    * @param pageSize
    * @param req
    * @return
    */
   @AutoLog(value = "假期申请记录查询-分页列表查询")
   @ApiOperation(value="假期申请记录查询-分页列表查询", notes="假期申请记录查询-分页列表查询")
   @GetMapping(value = "/list")
   public Result<?> queryPageList(LwgyHotelRequisition lwgyHotelRequisition,
                                  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                  HttpServletRequest req) {
       QueryWrapper<LwgyHotelRequisition> queryWrapper = null;
       queryWrapper = QueryGenerator.initQueryWrapper(lwgyHotelRequisition, req.getParameterMap());
                Page<LwgyHotelRequisition> page = new Page<>(pageNo, pageSize);
       LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
       List<String> roles = sysBaseAPI.getRolesByUsername(sysUser.getUsername());
       //管理员不限制
       //辅导员只看他自己学生申请
       if(roles.contains("fdy")){
           List<String> classId = lwgyBaseStudentService.getClassIdBySysUser(sysUser);
           if (oConvertUtils.listIsNotEmpty((classId))) {
               queryWrapper.in("t.student_class", classId);
           } else {
               queryWrapper.eq("t.student_class", "null");
           }
       }
       if (oConvertUtils.isNotEmpty(lwgyHotelRequisition.getStatus())) {
           queryWrapper.eq("t.status",lwgyHotelRequisition.getStatus());

       }
        IPage<LwgyHotelRequisition> pageList = lwgyHotelRequisitionService.queryHolidayPageList(page, queryWrapper);

       return Result.OK(pageList);
   }


    /**
     *   学生假期入住调宿
     *
     * @param lwgyHotelRequisition
     * @return
     */
    @AutoLog(value = "学生假期退宿-编辑")
    @ApiOperation(value="学生假期退宿-编辑", notes="学生假期退宿-编辑")
    @PostMapping(value = "/outBedEdit")
    public Result<?> outBedEdit(@RequestBody LwgyHotelRequisition lwgyHotelRequisition){
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
       /* String username = sysUser.getUsername();
        String stuUsername = oConvertUtils.isEmpty(lwgyHotelRequisition.getFromUser()) ? "admin":lwgyHotelRequisition.getFromUser();
*/
        QueryWrapper<LwgyBaseBed> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id").eq("holiday_student_id",lwgyHotelRequisition.getStudentId());
        List<LwgyBaseBed> lwgyBaseBeds = lwgyBaseBedMapper.selectList(queryWrapper);//查找该学生所有床位
        String content="";
        if(lwgyBaseBeds.size()>0){
            //先退宿
            LwgyBaseBed lwgyBaseBedT = lwgyBaseBeds.get(0);
            lwgyBaseBedT.setHolidayStudentId("");
            lwgyBaseBedService.updateById(lwgyBaseBedT);
            String bedCode = lwgyBaseBedT.getBedCode();

          /*  content = "管理员已经将你的假期床位清理："+lwgyBaseBedT.getCampusName()+"-"+lwgyBaseBedT.getBuildingName()
                    +"-"+lwgyBaseBedT.getUnitId()+"-"+lwgyBaseBedT.getLayerName()
                    +"-"+lwgyBaseBedT.getRoomName()+"-"+bedCode.substring(bedCode.length()-2)+"号床位，床位价格为："+lwgyBaseBedT.getBedPrice();
            sysBaseAPI.sendSysAnnouncement(new MessageDTO(username,stuUsername,"申请回执",content,"1"));

*/
        }
        return Result.OK("申请成功！");
    }


    /**
     * 学生假期批量退宿-没有推送消息
     *
     * @param hotelArrangeList
     * @return
     */
    @AutoLog(value = "学生假期批量退宿")
    @ApiOperation(value = "学生假期批量退宿", notes = "学生假期批量退宿")
    @PutMapping(value = "/batchOutBedEdit")
    public Result<?> batchOutBedEdit(@RequestBody List<Map<String, String>> hotelArrangeList) {
        List<String> ids = new ArrayList<>(hotelArrangeList.size());
        hotelArrangeList.stream().forEach(item -> ids.add(item.get("personId")));

        QueryWrapper<LwgyBaseBed> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("*");
        queryWrapper.in("holiday_student_id",ids);
        List<LwgyBaseBed> lwgyBaseBeds = lwgyBaseBedMapper.selectList(queryWrapper);//查找该学生所有床位
        if(lwgyBaseBeds.size()>0){
            for(LwgyBaseBed bed:lwgyBaseBeds){
                bed.setHolidayStudentId("");
                lwgyBaseBedService.updateById(bed);
            }
        }
        return Result.OK("退宿成功！");
    }

    /**
     *   学生假期宿舍从原床位同步-没有推送
     *
     * @param lwgyHotelRequisition
     * @return
     */
    @AutoLog(value = "学生假期同步入住")
    @ApiOperation(value="学生假期同步入住", notes="学生假期同步入住")
    @PutMapping(value = "/synBed")
    public Result<?> synBed(@RequestBody LwgyHotelRequisition lwgyHotelRequisition){
        String studentId=lwgyHotelRequisition.getStudentId();
        QueryWrapper<LwgyBaseBed> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id").eq("student_id",studentId);

        List<LwgyBaseBed> lwgyBaseBeds = lwgyBaseBedMapper.selectList(queryWrapper);
        if(lwgyBaseBeds.size()>0) {
            LwgyBaseBed lwgyBaseBed = lwgyBaseBeds.get(0);
            lwgyBaseBed.setHolidayStudentId(lwgyHotelRequisition.getStudentId());
            lwgyBaseBedService.updateById(lwgyBaseBed);
        }else{
            return Result.error("未找到学生宿舍无法同步，请手动安排！");
        }
        lwgyHotelRequisitionService.updateById(lwgyHotelRequisition);
        return Result.OK("入住成功！");
    }

    /**
     *   学生假期宿舍从原床位同步-没有推送
     *
     * @return
     */
    @AutoLog(value = "学生假期批量同步入住")
    @ApiOperation(value="学生假期批量同步入住", notes="学生假期批量同步入住")
    @PutMapping(value = "/batchSynBed")
    public Result<?> batchSynBed(@RequestBody List<Map<String, String>> hotelArrangeList){
        List<String> ids = new ArrayList<>(hotelArrangeList.size());
        hotelArrangeList.stream().forEach(item -> ids.add(item.get("personId")));

        QueryWrapper<LwgyBaseBed> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("*");queryWrapper.in("student_id",ids);

        List<LwgyBaseBed> lwgyBaseBeds = lwgyBaseBedMapper.selectList(queryWrapper);
        if(lwgyBaseBeds.size()>0) {
            for(LwgyBaseBed ll :lwgyBaseBeds){
                ll.setHolidayStudentId(ll.getStudentId());
                lwgyBaseBedService.updateById(ll);
            }

        }else{
            return Result.error("未找到学生宿舍无法同步，请手动安排！");
        }
        return Result.OK("入住成功！");
    }

    /**
     *   修改学生假期状态
     *
     * @return
     */
    @AutoLog(value = "修改学生假期状态")
    @ApiOperation(value="修改学生假期状态", notes="修改学生假期状态")
    @PutMapping(value = "/batchChangeState")
    public Result<?> batchChangeState(@RequestBody List<Map<String, String>> hotelArrangeList){
        List<String> ids0 = new ArrayList<>(hotelArrangeList.size());//0->1.
        List<String> ids1 = new ArrayList<>(hotelArrangeList.size());//1->0.
        hotelArrangeList.stream().forEach(item -> {
            if("0".equals(item.get("delFlag"))){
                ids0.add(item.get("personId"));
            }else{
                ids1.add(item.get("personId"));
            }
        });
        if(ids0.size()>0) {
            try{
                Integer a =  lwgyBaseBedMapper.updateStatusTo1(ids0) ;

            }catch(Exception e){
                return Result.error("操作失败！");
            }

            //id为ids0里面的所有数据，del_flag字段修改为1
           /*    QueryWrapper<LwgyHotelRequisition> queryWrapper = new QueryWrapper<>();
            queryWrapper.select("*");
            queryWrapper.in("student_id", ids0);

         List<LwgyHotelRequisition> lwgyHotelRequisitions = lwgyHotelRequisitionMapper.selectList(queryWrapper);
            if (lwgyHotelRequisitions.size() > 0) {
                for (LwgyHotelRequisition ll : lwgyHotelRequisitions) {
                    ll.setDelFlag("1");
                    lwgyHotelRequisitionService.updateById(ll);
                }
            }*/
        }
        if(ids1.size()>0){
            try{
                Integer a = lwgyBaseBedMapper.updateStatusTo0(ids1) ;

            }catch(Exception e){
                return Result.error("操作失败！");
            }

            //id为ids1里面的所有数据，del_flag字段修改为0
          /*  QueryWrapper<LwgyHotelRequisition> queryWrapper2 = new QueryWrapper<>();
            queryWrapper2.select("*");queryWrapper2.in("student_id",ids1);

            List<LwgyHotelRequisition> lwgyHotelRequisitions2 = lwgyHotelRequisitionMapper.selectList(queryWrapper2);
            if(lwgyHotelRequisitions2.size()>0) {
                for(LwgyHotelRequisition ll :lwgyHotelRequisitions2){
                    ll.setDelFlag("0");
                    lwgyHotelRequisitionService.updateById(ll);
                }
            }*/
        }
        return Result.OK("操作成功！");
    }


    /**
     *   切换为假期模式：学生修改为假期中，推送假期的住宿信息
     *
     * @return
     */
    @AutoLog(value = "开启假期模式")
    @ApiOperation(value="开启假期模式", notes="开启假期模式")
    @GetMapping(value = "/batchHolidayState")
    public Result<?> batchHolidayState(){
        List<String> id = new ArrayList<>();
        try{
            Integer a =  lwgyBaseBedMapper.updateStatusTo1(id) ;
            return Result.OK("操作成功！");
        }catch(Exception e){
            return Result.error("操作失败！");
        }


    }
    /**
     *   切换为开学模式：学生修改为开学中，推送正常的住宿信息
     *
     * @return
     */
    @AutoLog(value = "开启开学模式")
    @ApiOperation(value="开启开学模式", notes="开启开学模式")
    @GetMapping(value = "/batchGoSchoolState")
    public Result<?> batchGoSchoolState(){
        List<String> id = new ArrayList<>();
        try{
            Integer a = lwgyBaseBedMapper.updateStatusTo0(id) ;
            return Result.OK("操作成功！");
        }catch(Exception e){
            return Result.error("操作失败！");
        }
      /*  QueryWrapper<LwgyHotelRequisition> queryWrapper2 = new QueryWrapper<>();
        queryWrapper2.select("*");queryWrapper2.in("student_id",ids1);



        List<LwgyHotelRequisition> lwgyHotelRequisitions = lwgyHotelRequisitionMapper.selectList(queryWrapper2);
        if (lwgyHotelRequisitions.size() > 0) {
            for (LwgyHotelRequisition ll : lwgyHotelRequisitions) {
                ll.setDelFlag("1");
                lwgyHotelRequisitionService.updateById(ll);
            }
        }

        return Result.OK("操作成功！");*/
    }

    /**
     * 导出excel
     *
     * @param request
     * @param lwgyHotelRequisition
     */
    @RequestMapping(value = "/outHolidayStu")
    public ModelAndView outHolidayStu(HttpServletRequest request, LwgyHotelRequisition lwgyHotelRequisition) {
        List<LwgyHotelHoliday> lwgyHoliday = lwgyHotelRequisitionService.outHolidayStu(lwgyHotelRequisition);
        System.out.println("查询出的数据为:" + lwgyHoliday);
        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
        LwgyHotelHoliday lwgyHotelHoliday = new LwgyHotelHoliday();
        mv.addObject(NormalExcelConstants.FILE_NAME, "假期人员管理"); //此处设置的filename无效 ,前端会重更新设置一下
        mv.addObject(NormalExcelConstants.CLASS, LwgyHotelHoliday.class);
        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("假期人员管理", ""));
        mv.addObject(NormalExcelConstants.DATA_LIST, lwgyHoliday);
        return mv;
    }



    /**
     * 学生假期批量删除
     *
     * @param holidayList
     * @return
     */
    @AutoLog(value = "学生假期批量删除")
    @ApiOperation(value = "学生假期批量删除", notes = "学生假期批量删除")
    @PutMapping(value = "/batchDelete")
    public Result<?> batchDelete(@RequestBody List<Map<String, String>> holidayList) {
        String ids = "";
        for (Map<String, String> map : holidayList) {
            ids += map.get("id") + ",";
        }
        // 批量物理删除
        lwgyHotelRequisitionService.batchDelete(ids);
        return Result.OK("编辑成功!");
    }

    /**
     * 通过excel导入假期留校学生数据
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
        MultipartFile file = fileMap.get("file");
        try {
            long start = System.currentTimeMillis();
            ImportParams params = new ImportParams();
            params.setNeedSave(true);
            params.setTitleRows(2);//设置第一行为标题
            params.setHeadRows(1);//第三行为表头
            List<ImportHoildayStu> list = ExcelImportUtil.importExcel(file.getInputStream(), ImportHoildayStu.class, params);
            List<ImportHoildayStu> errList1 = new ArrayList<>();
            List<ImportHoildayStu> errList2 = new ArrayList<>();
            List<LwgyHotelHistory> arrangementList = new ArrayList<>();
            List<LwgyBaseBed> bedList = new ArrayList<>();
            List<LwgyHotelRequisition> requisitionList = new ArrayList<>();
            LwgyBaseBed lwgyBaseBed;
            LwgyHotelHistory lwgyHotelHistory;
            LwgyHotelRequisition lwgyHotelRequisition;

            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
            String username = sysUser.getUsername();
            List<String> roles = sysBaseAPI.getRolesByUsername(username);


            //通过导入的学生的姓名，学号，查询学生的id和班级
            list = lwgyHotelArrangementService.selectHoildayStudentIdList(list);

            //id为空的数据判断为学生不存在，写入errlist表中
            errList1 = list.stream().filter(item->oConvertUtils.isEmpty(item.getStudentId())&&oConvertUtils.isNotEmpty(item.getStudentNumber())).collect(Collectors.toList());
            if(errList1.size()>0){
                errList1.stream().forEach(item->{
                    item.setReason("学生不存在");
                });
            }
            list= list.stream().filter(item->oConvertUtils.isNotEmpty(item.getStudentId())||oConvertUtils.isEmpty(item.getStudentNumber())).collect(Collectors.toList());

            errList2 = list.stream().filter(item->oConvertUtils.isEmpty(item.getBedId())).collect(Collectors.toList());
            if(errList2.size()>0){
                errList2.stream().forEach(item->{
                    item.setReason("床位不存在");
                });
            }
            errList1.addAll(errList2);

            list= list.stream().filter(item->oConvertUtils.isNotEmpty(item.getBedId())).collect(Collectors.toList());

            Map<String, List<ImportHoildayStu>> collect1 = list.stream()
                    .filter(item-> StringUtils.isNotBlank(item.getStudentNumber())).collect
                            (Collectors.groupingBy(ImportHoildayStu::getStudentNumber));
            Map<String, List<ImportHoildayStu>> collect2 = list.stream()
                    .filter(item-> StringUtils.isNotBlank(item.getBedId())).collect
                            (Collectors.groupingBy(ImportHoildayStu::getBedId));
            Iterator<ImportHoildayStu> iterator=list.iterator();
            while (iterator.hasNext()){
                ImportHoildayStu importStuHotel = iterator.next();
                if(collect1.containsKey(importStuHotel.getStudentNumber())){
                    String a = importStuHotel.getStudentNumber();
                    if(collect1.get(a).size()>1){
                        importStuHotel.setReason("学号重复");
                        errList1.add(importStuHotel);
                        iterator.remove();
                        continue;
                    }
                }
                if(collect2.containsKey(importStuHotel.getBedId())){
                    if(collect2.get(importStuHotel.getBedId()).size()>1) {
                        importStuHotel.setReason("床位重复");
                        errList1.add(importStuHotel);
                        iterator.remove();
                        continue;
                    }
                }
            }
            //获取导入床位的名字，查询出id
            List<ImportHoildayStu> listBed = lwgyHotelArrangementService.selectBedByHoildayStuList(list);
            if (list.size() > 0) {
                String tsIds = "";
                String tsStuIds = "";
                String insertStuIds = "";
                for (int i = 0; i < list.size(); i++) {
                    ImportHoildayStu item = list.get(i);
                    ImportHoildayStu item2 = listBed.get(i);

                    lwgyBaseBed = new LwgyBaseBed();
                    lwgyHotelHistory = new LwgyHotelHistory();
                    lwgyHotelRequisition = new LwgyHotelRequisition();
                    // 安排假期住宿、插入历史记录、插入事务申请
                    if (oConvertUtils.isNotEmpty(item.getStudentId())) {
                        //insertStuIds += item.
                        lwgyBaseBed.setId(item.getBedId());
                        lwgyBaseBed.setHolidayStudentId(item.getStudentId());
                        lwgyBaseBed.setUpdateTime(new Date());
                        bedList.add(lwgyBaseBed);

                        lwgyHotelHistory.setBehavior("hoilday_bed");
                        lwgyHotelHistory.setPersonId(item.getStudentId());
                        lwgyHotelHistory.setAfterBed(item.getBedId());
                        arrangementList.add(lwgyHotelHistory);

                        lwgyHotelRequisition.setStudentId(item.getStudentId());
                        lwgyHotelRequisition.setStudentName(item.getStudentName());
                        lwgyHotelRequisition.setStudentNumber(item.getStudentNumber());
                        lwgyHotelRequisition.setStudentCampus("1");
                        lwgyHotelRequisition.setBehavioral("hoilday_bed");
                        lwgyHotelRequisition.setStudentCollege(item.getStudentCollege());
                        lwgyHotelRequisition.setStudentYear(item.getStudentYear());
                        lwgyHotelRequisition.setStudentMajor(item.getStudentMajor());
                        lwgyHotelRequisition.setStudentClass(item.getStudentClass());
                        lwgyHotelRequisition.setCampusId(item2.getCampusId());
                        lwgyHotelRequisition.setBuildingId(item2.getBuildingId());
                        lwgyHotelRequisition.setUnitId(item2.getUnitId());
                        lwgyHotelRequisition.setLayerId(item2.getLayerId());
                        lwgyHotelRequisition.setRoomId(item2.getRoomId());
                        lwgyHotelRequisition.setRoomsex(item.getRoomSex());
                        lwgyHotelRequisition.setProcessingState("1");
                        lwgyHotelRequisition.setProcessingResult("1");
                        lwgyHotelRequisition.setReason(item.getReason());
                        lwgyHotelRequisition.setStayStartTime(item.getStayStartTime());
                        lwgyHotelRequisition.setStayEndTime(item.getStayEndTime());
                        lwgyHotelRequisition.setPhoneNumber(item.getPhoneNumber());
                        lwgyHotelRequisition.setTeacherName(item.getTeacherName());
                        requisitionList.add(lwgyHotelRequisition);
                    }
                }
                if (bedList.size() > 0) {
                    lwgyBaseBedService.updateBatchById(bedList);//更新入住信息
                    lwgyHotelHistoryService.saveBatch(arrangementList);//保存历史记录
                    lwgyHotelRequisitionService.saveBatch(requisitionList);//保存事务申请
                }
            }
            long end = System.currentTimeMillis();

            if (errList1.size() == 0) {
                Map paramsMsg = new HashMap();
                paramsMsg.put("message", "成功导入" + list.size() + "条数据,共耗时:" + (end - start) / 1000 + "秒");
                return Result.OK(paramsMsg);
            } else {
                Map paramsMsg = new HashMap();
                paramsMsg.put("message", "成功导入" + list.size() + "条数据，共耗时:" + (end - start) / 1000 + "秒，存在" + errList1.size() + "条问题数据，是否导出？");
                paramsMsg.put("data", errList1);
                return Result.OK(paramsMsg);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.OK();
    }

    /**
     * 导入excel模板
     *
     * @param request
     * @param
     */
    @RequestMapping(value = "/outHolidayStuTemplate")
    public ModelAndView outHolidayStuTemplate(HttpServletRequest request, LwgyBaseBed lwgyBed) {
        List<ImportHoildayStu> lwgyBaseBed = new ArrayList<>(1);
        ImportHoildayStu importStuHotel = new ImportHoildayStu();

        importStuHotel.setBuildingName("GA14(必填)");
        importStuHotel.setRoomName("101(必填)");
        importStuHotel.setBedName("01(必填)");
        importStuHotel.setReason("寒假住宿(必填)");
        importStuHotel.setStudentName("姓名(必填)");
        importStuHotel.setStudentNumber("202400000001(必填)");
        importStuHotel.setStayStartTime("2024-09-01(必填)");
        importStuHotel.setStayEndTime("2024-09-01(必填)");
        importStuHotel.setPhoneNumber("联系方式(必填)");
        importStuHotel.setTeacherName("辅导员/导师姓名(必填)");

        lwgyBaseBed.add(importStuHotel);
        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
        //此处设置的filename无效 ,前端会重更新设置一下
        mv.addObject(NormalExcelConstants.FILE_NAME, "假期人员信息");
        mv.addObject(NormalExcelConstants.CLASS, ImportHoildayStu.class);
        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("假期人员信息表", "导入要求:严格按照模板进行填写,复制粘贴进来的数据清除一下格式再进行导入","人员信息"));
        mv.addObject(NormalExcelConstants.DATA_LIST, lwgyBaseBed);
        return mv;
    }
}
